$(function () {
    $("#jqGrid").Grid({
        url: '../modulemaintainoptions/list?isEffect=1&optionType=0',
        colModel: [
            {label: '序号', name: 'orNum', index: 'OR_NUM', width: 80},
            {label: '一级名称', name: 'optionSubclass', index: 'optionSubclass', width: 80},
            {label: '二级名称', name: 'optionName', index: 'OPTION_NAME', width: 80},
            {label: '方法手段', name: 'method', index: 'METHOD', width: 80},
            {label: '实施频率', name: 'implPre', index: 'IMPL_PRE', width: 80,
                formatter: function (value) {
                    if(value==null||value==""){
                        return "暂无"
                    }else{
                        return sysEnums.FRERATE[value];
                    }
                }
            },
            {label: '检查标准', name: 'inspectStandard', index: 'INSPECT_STANDARD', width: 80},
            {label: '选项备注', name: 'optionRemark', index: 'OPTION_REMARK', width: 80},
            {label: '记录', name: 'rocords', index: 'ROCORDS', width: 80},
            {label: 'id', name: 'id', index: 'ID', key: true, hidden: true},
        ]
    });
});

var vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        q: {
            name: '',
            optionType: '',
            method: ''
        },
        implPreList:enumsToList("FRERATE2"),
    },
    methods: {
        query: function () {
            vm.reload();
        },
        //保存数据到维护规程选项关联表数据
        add: function () {
            vm.showList = false;
            vm.title = "新增";
            vm.moduleMaintainOptions = {
                updateDate: '',
                updateUser: '',
                createDate: '',
                createUser: '',
                delFlag: '',
                rocords: '',
                noProductDate: '',
                productDate: '',
                optionRemark: '',
                inspectStandard: '',
                method: '',
                optionSubclass: '',
                optionType: '',
                optionName: '',
            };
        },
        reload: function (event) {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                postData: {'name': vm.q.name, "optionType": vm.q.optionType, "method": vm.q.method},
                page: page
            }).trigger("reloadGrid");
            vm.handleReset('formValidate');
        },
        reloadSearch: function () {
            vm.q = {
                name: '',
                optionType: '',
                method: ''
            };
            vm.reload();
        },
        handleSubmit: function (name) {
            handleSubmitValidate(this, name, function () {
                vm.saveOrUpdate()
            });
        },
        handleReset: function (name) {
            handleResetForm(this, name);
        }
    }
});

var getBaseOp = function () {
    let result = getSelectedRowData("#jqGrid");
    var id = result.id;
    if (id == null) {
        return false;
    } else {
        return result;
    }
}